﻿@model SyndicationFeed
@{
    var hideAdvertisements = EngineContext.Current.Resolve<CommonSettings>().HideAdvertisementsOnAdminArea;
}
@using System.ServiceModel.Syndication;
@using Nop.Core.Domain.Common;
<div class="nop-news">
    <div class="section-header">
        <div class="title">
            <img src="@Url.Content("~/Administration/Content/images/ico-news.gif")" alt="" />
            @T("Admin.NopCommerceNews")
        </div>
    </div>
    <div class="newsitem">
        @foreach (var item in Model.Items)
        {
            <div class="newstitle">
                @if (item.Links.Count > 0)
                {
                    <a href='@(item.Links[0].Uri.OriginalString)'>@item.Title.Text</a>
                }
                else
                {
                    @item.Title.Text
                }
            </div>
            <div class="newsdate">
                @item.PublishDate.ToString("d")
            </div>
            <div class="newsdetails">
                @Html.Raw(@item.Summary.Text)
            </div>
            
        }
    </div>
    <div class="clear">
    </div>
    <div class="adv">
        <a id="nopcommerceNewsHideAdv" href="#">@(hideAdvertisements ? T("Admin.NopCommerceNews.ShowAdv") : T("Admin.NopCommerceNews.HideAdv"))</a>
        <script type="text/javascript">
        
        $(document).ready(function () {
            $('#nopcommerceNewsHideAdv').click(function () {
                $.ajax({
                    cache:false,
                    type: "POST",
                    url: "@(Url.Action("NopCommerceNewsHideAdv", "Home"))",
                    success: function (data) {
                         location.reload();
                    },
                    error:function (xhr, ajaxOptions, thrownError){
                        alert('Failed to change setting.')
                    }  
                });
            });
        });

        </script>
    </div>
</div>
